package com.gerencia.view;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import static java.lang.Thread.sleep;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

/**
 *
 * @author icarlos
 */
public class SplashFrame extends JFrame {

    FileWriter fw;
    BufferedWriter bw;

    public static String path[] = {" - start/inicio - ", "/home/user/test.dat", "/home/user/archive", "./expensive", "/directory/strauss", "/frame/jars/jaws", "./blackship/files", "/directory/trademark", "?/parlaphone/StringBuilder/traxart", "@position_memories", "clara_de_ovo",
        "/goss/satangoss/?direx", "~pente/~fino", "<dist>/^blob", "/carmagedon/killed/killall java", "black/label/society", "./dist/inst/clip/", "/home/user/Documents/NetBeans/Projects/extensable", "flash/friedsable/chroma/klein",
        "~/dist/ṽivaz/teste", "./klein/ultraje/bloco_de_notas", "stone_temple_pilots/plush/sound.mp3", "xtense.nop", "sudo apt-get install <archive>", ".yum", "/netbeans.sh", "clash?the_clash", "$%$**", "clap/your?/hands?/~dist", "tcpdump/clipart", "blob:-/clap/stringconex",
        "/<dist>/archive/files/tester.azon", "?clap/!staff/directory/gore", "tcpdump/pegazus/seya", ".../...", "&\\disturbed/x", "lazarus/icarus/tux", "%december", "/water/fire/earth/love", "blink_182/violence", "smell-like_teen_spirits",
        "sudo sh netbeans-8.0-javase-linux.sh", "xtense.nop", "yum.", "sudo apt-get install <archive>", "/netbeans.sh", "clash?the_clash", "$%$**", "clap/your?/hands?/~dist", "tcpdump/clipart", "blob:-/clap/stringconex",
        "/gass/faith/for/full~/stalin", "~satangoss/!dailion/jaspion", "~archive.txt", "c://Documents/tester.doc", "conect to amazon server", "alocal", "britzieg-bop", "./<facade>/?bench", "somos./oque/tester?/nunca!", "nerver die",
        "mira/guaco/garnilón", "/disc/10.000/destinos/negro_amor", "adal/fonseca", ".tester@", "@menorzera/archive/~filechooser/negro.amor", "expensive^-juli", "#/%-&*(trim)", "jLabelCharger.setText(path[i].trim().toString())",
        "./Engenheiros/Hawaii/10.000/Destinos/Negro_Amor.MP3", "coma_guitar", "stone_temple_pilots/plush/sound.mp3", "xtense.nop", "yum.", "sudo apt-get install <archive>", "/netbeans.sh", "clash?the_clash", "$%$**", "clap/your?/hands?/~dist", "tcpdump/clipart", "blob:-/clap/stringconex",
        "tree", "user@user-machine:~$", "scada.dat", "batera<lsi>/?/adal/fonseca", "click jogos", "YUM.adobe.flash.player", "tar.gz.sh-risk", "tar/star/retar", "A melhor banda de todos os tempos da ultima semana", "/home/user/NetBeansProjects",
        "jasper/jabx/java/jar/jaws/jFileChooser/.jar", "plush:/~plush/?stp/~:$wow", "crazytown-:$", "jar/jaws/jax/jiraya/janis/joplin/.jar", "methodes*&#@!%cpip", "hudson-datamachine", "§ql-§erver§", "/satangoss/$tree", "kylix/netflix",
        "/Documents/Archive/prinkler/chronicles", "Done!"};

    public SplashFrame() {
        try {
            initComponents();
            UIManager.setLookAndFeel(new NimbusLookAndFeel());
            new Thread() {
                @Override
                public void run() {
                    for (int i = 0; i < 102 && i < path.length; i++) {
                        try {
                            jProgressBar.setValue(i);
                            jLCharger.setText(path[i].trim().toString());
                            sleep(45);
                        } catch (InterruptedException ex) {
                            Logger.getLogger(SplashFrame.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                    System.out.println("tam: " + path.length);
                    new Login().setVisible(true);
                }
            }.start();

            fw = new FileWriter("/home/icarlos/NetBeansProjects/GerenciaCondominio/src/com/gerencia/log/splash_path");
            bw = new BufferedWriter(fw);

            for (int i = 0; i < path.length; i++) {
                bw.write(path[i].trim().toString());
            }
            bw.newLine();
            bw.close();
        } catch (IOException | UnsupportedLookAndFeelException ex) {
            Logger.getLogger(SplashFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        image = new javax.swing.JLabel();
        jLCharger = new javax.swing.JLabel();
        jProgressBar = new javax.swing.JProgressBar();
        carga = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);
        getContentPane().setLayout(null);

        image.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/gerencia/image/SiteGrupoPolo.png"))); // NOI18N
        getContentPane().add(image);
        image.setBounds(0, 0, 490, 200);

        jLCharger.setFont(new java.awt.Font("Arial", 3, 12)); // NOI18N
        jLCharger.setForeground(new java.awt.Color(73, 48, 143));
        jLCharger.setText("Charger");
        getContentPane().add(jLCharger);
        jLCharger.setBounds(260, 160, 210, 15);
        getContentPane().add(jProgressBar);
        jProgressBar.setBounds(4, 186, 480, 10);

        carga.setFont(new java.awt.Font("Arial", 3, 12)); // NOI18N
        carga.setForeground(new java.awt.Color(73, 48, 143));
        carga.setText("carregando... ");
        getContentPane().add(carga);
        carga.setBounds(180, 160, 80, 15);

        setSize(new java.awt.Dimension(493, 201));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SplashFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new SplashFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel carga;
    private javax.swing.JLabel image;
    private javax.swing.JLabel jLCharger;
    private javax.swing.JProgressBar jProgressBar;
    // End of variables declaration//GEN-END:variables
}
